﻿using System;
using System.Collections.Generic;
using GeoAPI.Geometries;
using NetTopologySuite.Geometries;

namespace HYCodeBase.TopologySuite
{
	internal static class TopologySuiteUtility
	{
		internal static List<LineString> GetNodedLineString(List<LineString> inputLineString, bool ifPersistinput = false)
		{
			List<LineString> list = new List<LineString>();
			if (ifPersistinput)
			{
				list.AddRange(inputLineString);
			}
			if (inputLineString == null || inputLineString.Count == 0)
			{
				return list;
			}
			int num = 0;
            IGeometry geometry = inputLineString[num];
			for (int i = num + 1; i < inputLineString.Count; i++)
			{
                geometry = (IGeometry)geometry.Union(inputLineString[i]);
			}
			if (geometry is MultiLineString)
			{
				IEnumerator<IGeometry> enumerator = (geometry as MultiLineString).GetEnumerator();
				{
					while (enumerator.MoveNext())
					{
						IGeometry geometry2 = enumerator.Current;
						if (geometry2 is LineString)
						{
							list.Add(geometry2 as LineString);
						}
					}
					return list;
				}
			}
			if (geometry is LineString)
			{
				list.Add(geometry as LineString);
			}
			return list;
		}
	}
}
